import { _decorator, Component, Node, Vec3 } from 'cc';
import { eShiohoEvent, shiohoEventManager } from '../event/shiohoEventManager';
import { guideFinger } from '../guide/guideFinger';
const { ccclass, property } = _decorator;

@ccclass('weakPanel')
export class weakPanel extends Component {

    @property(guideFinger)
    guideFinger: guideFinger;

    onEnable() {
        this.activeFinger(false);
        shiohoEventManager.getInstance().addObserver(eShiohoEvent.StepOver, this.onClick.bind(this));
    }

    onDisable() {
        shiohoEventManager.getInstance().removeObserver(eShiohoEvent.StepOver, this.onClick.bind(this));
    }

    public activeSelf(isShow: boolean) {
        this.node.active = isShow;
    }

    public updateFingerPos(pos: Vec3) {
        this.guideFinger.node.worldPosition = pos;
        this.activeFinger(true);
    }

    private activeFinger(isShow: boolean) {
        this.guideFinger.activeFinger(isShow);
        this.guideFinger.activeAnima(true);
    }

    private onClick() {
        this.activeFinger(false);
    }

}


